#include <iostream>
#include <string>
#include <queue>
#include <stack>
using namespace std;

int main()
{
	int n, k; cin >> n >> k;
	vector<int> arr(n);
	for (auto& e : arr) cin >> e;
	int tgt = arr[k], ans = 0;
	for (int i = 0; i < n; i++) {
		if (i <= k) ans += min(tgt, arr[i]);
		else ans += min(tgt - 1, arr[i]);
	}
	cout << ans;

	return 0;
}